package com.augurit.gzcgwsp.jzfqwczz.common.convert;

import java.util.ArrayList;
import java.util.List;
import org.dozer.DozerBeanMapper;
import com.augurit.gzcgwsp.jzfqwczz.common.entity.YwYnBusinfoHfqk;
import com.augurit.gzcgwsp.jzfqwczz.common.web.form.YwYnBusinfoHfqkForm;

public class YwYnBusinfoHfqkConvertor {
	public static YwYnBusinfoHfqkForm convertVoToForm(YwYnBusinfoHfqk entity) {
		if (entity == null) return null;
		
		return new DozerBeanMapper().map(entity, YwYnBusinfoHfqkForm.class);
	}
	
	public static void convertFormToVo(YwYnBusinfoHfqkForm form, YwYnBusinfoHfqk entity) {
		if (form == null) return;
        if (entity == null) entity = new YwYnBusinfoHfqk();
        
        new DozerBeanMapper().map(form, entity);
	}
	
	public static List<YwYnBusinfoHfqkForm> convertVoListToFormList(List<YwYnBusinfoHfqk> ywYnBusinfoHfqkList) {
		if(ywYnBusinfoHfqkList != null && ywYnBusinfoHfqkList.size() > 0) {
			List<YwYnBusinfoHfqkForm> ywYnBusinfoHfqkFormList = new ArrayList<YwYnBusinfoHfqkForm>();
			for(int i=0; i<ywYnBusinfoHfqkList.size(); i++) {
				ywYnBusinfoHfqkFormList.add(convertVoToForm(ywYnBusinfoHfqkList.get(i)));
			}
			return ywYnBusinfoHfqkFormList;
		}
		return null;
	}
	
	public static List<YwYnBusinfoHfqk> convertFormListToVoList(List<YwYnBusinfoHfqkForm> ywYnBusinfoHfqkFormList) {
		if(ywYnBusinfoHfqkFormList != null && ywYnBusinfoHfqkFormList.size() > 0) {
			List<YwYnBusinfoHfqk> ywYnBusinfoHfqkList = new ArrayList<YwYnBusinfoHfqk>();
			for(int i=0; i<ywYnBusinfoHfqkFormList.size(); i++) {
				YwYnBusinfoHfqk ywYnBusinfoHfqk = new YwYnBusinfoHfqk();
				convertFormToVo(ywYnBusinfoHfqkFormList.get(i), ywYnBusinfoHfqk);
				ywYnBusinfoHfqkList.add(ywYnBusinfoHfqk);
			}
			return ywYnBusinfoHfqkList;
		}
		return null;
	}
}